<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test23</title>
</head>
<body>
    <script type="text/javascript">
        Sum();
        function Sum() {
            var arr = [18,45,333,5,6,1,5]
            var sum = 0;
            for(var i = 0; i<arr.length; i++){
                sum+=arr[i];
            }
            alert("所有元素的和为："+sum);
        }
    </script>
</body>
</html>